package com.yantu.controller.student;

import com.yantu.bean.Subject;
import com.yantu.mapper.SubjectMapper;
import com.yantu.util.Result;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@RestController
@ApiModel("学科列表")
@RequestMapping("/student")
public class StudentSubjectListController {



    @Autowired
    SubjectMapper SubjectMapper;


    //学科列表
    @GetMapping("/subjectList")
    @ApiOperation("学科列表")
    public Result subjectList() {

        List<Subject> subjects = SubjectMapper.selectList(null);
        List<Object> list = new ArrayList();
        for (Subject subject : subjects) {
            HashMap<String, Object> map = new HashMap<>();
            map.put("id",subject.getId());
            map.put("name",subject.getName());
            list.add(map);
        }

        return Result.succ(200, "查询成功", list);

    }
}
